package com.imoblife.brainwavestus;

import java.io.IOException;
import org.xmlpull.v1.XmlPullParserException;
import android.os.Bundle;
import com.imoblife.brainwavestus.customview.UserProduct;

public class UserProductActivity extends BaseActivity {

	UserProduct mUserProduct;

	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);

		if (mUserProduct == null) {
			mUserProduct = new UserProduct(this);
		}

		if (mUserProduct.isXLargerScreen()) {

			setContentView(R.layout.tb_product_layout);

		} else {
			setContentView(R.layout.user_product_layout);
		}

		try {
			mUserProduct.initInfo();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (XmlPullParserException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		mUserProduct.setAction();
	}

	protected void onStart() {
		super.onStart();
		initTitleName(getString(R.string.library));
	}

	protected void onPause() {
		mUserProduct.unRegisterDownloadingListener();
		super.onPause();
	}

	protected void onStop() {
		super.onStop();
	}

	protected void onResume() {
		super.onResume();
		mUserProduct.updatePlayList();
		mUserProduct.registerDownloadingListener();
	}

	protected void onDestroy() {
		mUserProduct.release();
		super.onDestroy();
		System.gc();
	}

}
